home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / tess / tess-1.0 / p3.m < prev    next >
Encoding:
Text File  |  1992-06-30  |  1.2 KB  |  69 lines

  1. #import "p3.h"
  2.  
  3. @implementation p3
  4. - defaultConfig
  5. {
  6.   [self noAngleSetup];
  7.   return self;
  8. }
  9.  
  10. - resizeGenerator
  11. {
  12.   latticesize.height = 3.0 * bounds.size.height / 2.0;
  13.   latticesize.width = bounds.size.width * 2;
  14.   upx = bounds.size.width;
  15.   upy = bounds.size.height;
  16.   overx = latticesize.width;
  17.   return self;
  18. }
  19.  
  20. - clip: (NXCoord) x: (NXCoord) y 
  21.   PSnewpath();
  22.   PSmoveto(x,y);
  23.   PSrmoveto(0,bounds.size.height/3.0);
  24.   PSrlineto(0, 2 * bounds.size.height / 3.0);
  25.   PSrlineto(bounds.size.width,-bounds.size.height/3.0);
  26.   PSrlineto(0,2.0 * -bounds.size.height /3.0);
  27.   PSclosepath();
  28.   PSclip();
  29.   return self;
  30. }
  31.  
  32. - makeLatticeUnitAt: (NXPoint *) point fromImage: srcimg 
  33. {
  34.   id imgrep;
  35.   int i;
  36.   NXPoint pt;
  37.   
  38.   pt.x = - point->x ;
  39.   pt.y = - point->y ;
  40.   imgrep = [srcimg bestRepresentation];
  41.   for(i=0;i<3;i++){
  42.     PSgsave();
  43.     PStranslate(0,bounds.size.height/3);
  44.     PSrotate(120*i);
  45.     PStranslate(0,-bounds.size.height/3);
  46.     [self clip:0.0:0.0];
  47.     [imgrep drawAt: &pt];
  48.     PSgrestore();
  49.   }
  50.   return self;
  51. }
  52. - (BOOL)isRigidLattice { return YES; };
  53. - sizeKludge: (float *) x : (float *) y
  54. {
  55.   float hyp;
  56.  
  57.   hyp = *y / 3.0 * 2.0;
  58.   *x = [self equi: hyp];
  59.   return self;
  60. }
  61.  
  62. - (float)equi: (float) side
  63. {
  64.   return sqrt(3)/2 * side;
  65. }
  66.  
  67. @end
  68.